<template>
	<view class="content">
		<view @click="itemClick(index)" class="flex-row-start item1" style="position: relative;" v-for="(item,index) in dataArr" :key="index">
			<image  style="width: 30rpx; height: 30rpx; margin-right: 20rpx;" :src="item.pic"></image>
			<view style="font-size: 28rpx;">{{item.title}}</view>
			<image  style="position: absolute; top: 0rpx; right: 30rpx; width: 15rpx; height: 82rpx;" mode="aspectFit" src="/static/arrow/arrow-right-black.png"></image>
			
			
		</view>
		
		
	</view>
</template>

<script>
	import {login} from '@/api/api.js'
	
	export default {
		data() {
			return {
				dataArr:[{title:'个人发布',pic:'/static/publish-index.png'},
				{title:'个人发布管理',pic:'/static/publish-manage.png'},
				{title:'机构发布',pic:'/static/publish-index.png'},
				{title:'机构发布管理',pic:'/static/publish-manage.png'},
				{title:'球馆发布',pic:'/static/publish-index.png'},
				{title:'球馆发布管理',pic:'/static/publish-manage.png'}]
				
			}
		},
		onLoad(){			
			// uni.removeStorageSync('publish-mix-token')
			var token = uni.getStorageSync('publish-mix-token')
			if (!token){
				uni.login({
					success: (res) => {
						setTimeout(res1 => {
							this.requestLogin(res.code)
						}, 500)
					},
					fail: () => {
						uni.hideLoading()
					}
					
				})
				
				return
			}
		},
		methods: {
			itemClick(index){
				var url = ''
				if (index == 0){
					url = '/pages/publish/personalPublish'
				}
				if (index == 1){
					url = '/pages/publish/publishList?type=1'
				}
				if (index == 2){
					url = '/pages/publish/agencyPublish'	
				}
				if (index == 3){
					url = '/pages/publish/publishList?type=2'
				}
				if (index == 4){
					url = '/pages/publish/ballPublish'	
				}
				if (index == 5){
					url = '/pages/publish/publishList?type=3'
				}
				uni.navigateTo({
					url:url
				})
			},
			requestLogin(code){
				login({open_id_code:code}).then(res=>{
					if(res.data.code == 200){
						var data = res.data.data
						uni.setStorageSync('publish-mix-token',data.info.utoken)
						return
						
					}
					uni.$u.toast(res.data.message)
					
				})
				
			}
			
		}
	}
</script>

<style lang="scss">
	.item1{
		box-sizing: border-box;
		
		width: 100%;
		height: 82rpx;
		padding: 0rpx 30rpx;
		border-bottom: 1px solid rgb(238, 238, 238);

		
		
	}

</style>
